from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("http://cn.bing.com")
# 最小化窗口
driver.minimize_window()
sleep(2)
# 浏览器大小控制
driver.set_window_size(500,500)
sleep(2)
# 最大化窗口
driver.maximize_window()
sleep(2)
# 获取当前网页的title、url和handle
title1 = driver.title
url1 = driver.current_url
handle1 = driver.current_window_handle
print("title1:%s"%title1)
print("url1:%s"%url1)
print("handle1:%s"%handle1)
# 浏览器前进后退
driver.find_element_by_link_text("视频").click()
sleep(3)
# 获取当前网页的title、url和handle
title2 = driver.title
url2 = driver.current_url
handle2 = driver.current_window_handle
print("\ntitle2:%s"%title2)
print("url2:%s"%url2)
print("handle2:%s"%handle2)
# 获取浏览器类型
browser = driver.name
print("\nbrowser:%s"%browser)
# 前进
driver.back()
sleep(2)
# 后退
driver.forward()
sleep(2)
# 刷新
driver.refresh()
sleep(2)
# 退出当前页面
driver.close()
# 退出驱动程序
driver.quit()

# 层级定位补充
# driver.find_element(By.XPATH, "//form/p[@id='pa']/input[@type='text']").send_keys("admin")



















